home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / tcl / colors.tk < prev    next >
Encoding:
Text File  |  1992-07-17  |  4.3 KB  |  176 lines

  1. #
  2. # colors.tk --
  3. #    setColorCube is used to pick a set of 4 complementary colors
  4. #
  5.  
  6. # random, unused colors
  7. #set chocolate        #ae7359
  8. #set maroon        #b03060
  9. #set lightblue2        #b2dfee
  10. #set lightpink1        #ffaeb9
  11.  
  12.  
  13. # Default color values
  14. #    A suite of 4 (possibly 5) colors is defined together:
  15. #    backgroundColor:    Used for frame backgrounds, darkish
  16. #    paleBackground:        Used for label, entry, message, scroll_bg
  17. #    passiveColor:        listbox_bg, scroll_fg, buttons
  18. #    activeColor:        buttons, scroll_sel, listbox_select
  19.  
  20. global currentCube
  21. global screenDepth
  22.  
  23. set currentCube blue
  24. set screenDepth unknown
  25.  
  26. proc setTestCube { } {
  27.     global backgroundColor paleBackground foregroundColor passiveColor activeColor
  28.     set backgroundColor        blue
  29.     set paleBackground        pink
  30.     set foregroundColor        black
  31.     set passiveColor        yellow
  32.     set activeColor        red
  33. }
  34.  
  35. proc setBlueCube { } {
  36.     global backgroundColor paleBackground foregroundColor passiveColor activeColor
  37.     set backgroundColor    [format "#%02x%02x%02x" 128 128 200]
  38.     set paleBackground        #e4f4fe
  39.     set foregroundColor        black
  40.     set passiveColor        #acd6f1
  41.     set activeColor        #61acde
  42. }
  43.  
  44. proc setRedCube { } {
  45.     global backgroundColor paleBackground foregroundColor passiveColor activeColor
  46.     set backgroundColor        #cd8e91
  47.     set paleBackground        #fddede
  48.     set foregroundColor        black
  49.     set passiveColor        #ffb5b9
  50.     set activeColor        #cd6368
  51. }
  52.  
  53. proc setGreenCube { } {
  54.     global backgroundColor paleBackground foregroundColor passiveColor activeColor
  55.     set backgroundColor        #32cd83
  56.     set paleBackground        #d9ffe6
  57.     set foregroundColor        black
  58.     set passiveColor        #b2f6ab
  59.     set activeColor        #13cd00
  60. }
  61.  
  62. proc setPurpleCube { } {
  63.     global backgroundColor paleBackground foregroundColor passiveColor activeColor
  64.     set backgroundColor        #cb02dd
  65.     set paleBackground        #ffceff
  66.     set foregroundColor        black
  67.     set passiveColor        #eeadf3
  68.     set activeColor        #f154ff
  69. }
  70.  
  71. proc setBisqueCube { } {
  72.     global backgroundColor paleBackground foregroundColor passiveColor activeColor
  73.     # These are the TK defaults from default.h
  74.     set bisque1            #ffe4c4
  75.     set bisque2            #eed5b7
  76.     set bisque3            #cdb79e
  77.  
  78.     set backgroundColor        $bisque3    
  79.     set paleBackground         $bisque1
  80.     set foregroundColor        black
  81.     set activeColor         $bisque2
  82.     set passiveColor        $bisque1
  83. }
  84.  
  85. proc setBrownCube { } {
  86.     global backgroundColor paleBackground foregroundColor passiveColor activeColor
  87.     # These are the TK defaults from default.h
  88.     set bisque1            #ffe4c4
  89.     set bisque2            #eed5b7
  90.     set bisque3            #cdb79e
  91.     set chocolate        #ae7359
  92.  
  93.     set backgroundColor        $chocolate    
  94.     set paleBackground         $bisque1
  95.     set foregroundColor        black
  96.     set activeColor         $bisque3
  97.     set passiveColor        $bisque2
  98. }
  99.  
  100. # For 4-bits of grey - a la Tadpole screen.  Cannot get X server to work yet.
  101. proc setGray4Cube { } {
  102.     global backgroundColor paleBackground foregroundColor passiveColor activeColor
  103.     global currentCube
  104.  
  105.     set backgroundColor    black
  106.     set paleBackground    white
  107.     set foregroundColor    black
  108.     set passiveColor    white
  109.     set activeColor    black
  110.  
  111.     set currentCube Gray4
  112. }
  113.  
  114. proc setBWCube { } {
  115.     global backgroundColor paleBackground foregroundColor passiveColor activeColor
  116.     global currentCube
  117.  
  118.     set backgroundColor    black
  119.     set paleBackground    white
  120.     set foregroundColor    black
  121.     set passiveColor    white
  122.     set activeColor    black
  123.  
  124.     set currentCube BW
  125. }
  126.  
  127. proc setColorCube { { cube "blue" } } {
  128.     global backgroundColor paleBackground foregroundColor \
  129.         passiveColor activeColor currentCube
  130.  
  131.     case [screendepth] in {
  132.     8 {
  133.         case $cube in {
  134.         {$currentCube} {  } 
  135.         {default "blue"} { setBlueCube } 
  136.         "red" { setRedCube } 
  137.         "green" { setGreenCube } 
  138.         "purple" { setPurpleCube } 
  139.         "bisque" { setBisqueCube } 
  140.         "brown" { setBrownCube }
  141.         }
  142.     }
  143.     4 {
  144.         setGray4Cube
  145.     }
  146.     1 {
  147.         setBWCube
  148.     }
  149.     default {
  150.         puts stderr "setColorCube unknown screendepth [screendepth]"
  151.         setBWCube
  152.     }
  153.     }
  154.     set currentCube $cube
  155.     return $currentCube
  156. }
  157.  
  158. proc getColorCube { } {
  159.     global currentCube
  160.     return $currentCube
  161. }
  162.  
  163. proc screendepth {} {
  164.     global screenDepth
  165.     if {$screenDepth == "unknown"} {
  166.     if [catch {winfo screendepth} screenDepth] {
  167.         set _d [exec xwininfo -root | egrep Depth:]
  168.         set screenDepth [lindex $_d [expr [llength $_d]-1]]
  169.     }
  170.     }
  171.     return $screenDepth
  172. }
  173.  
  174. setColorCube
  175.